﻿@{
    var defaultGridPageSize = EngineContext.Current.Resolve<SDF.Core.Domain.Common.AdminAreaSettings>().DefaultGridPageSize;
    var gridPageSizes = EngineContext.Current.Resolve<SDF.Core.Domain.Common.AdminAreaSettings>().GridPageSizes;

    //page title
    ViewBag.Title = T("Admin.ReturnRequests").Text;
    //active menu item (system name)
    Html.SetActiveMenuItemSystemName("Return requests");
}

@Html.AntiForgeryToken()
<div class="content-header clearfix">
    <h1 class="pull-left">
        @T("Admin.ReturnRequests")
    </h1>
    <div class="pull-right">
        &nbsp;
    </div>
</div>

<div class="content">
    <div class="form-horizontal">
        <div class="panel-group">
            <div class="panel panel-default">
                <div class="panel-body">
                    <p>
                        @T("Admin.ReturnRequests.Description")
                    </p>
                    <div id="returnrequests-grid"></div>

                    <script>
                        $(document).ready(function() {
                            $("#returnrequests-grid").kendoGrid({
                                dataSource: {
                                    type: "json",
                                    transport: {
                                        read: {
                                            url: "@Html.Raw(Url.Action("List", "ReturnRequest"))",
                                            type: "POST",
                                            dataType: "json",
                                            data: addAntiForgeryToken
                                        }
                                    },
                                    schema: {
                                        data: "Data",
                                        total: "Total",
                                        errors: "Errors"
                                    },
                                    error: function(e) {
                                        display_kendoui_grid_error(e);
                                        // Cancel the changes
                                        this.cancelChanges();
                                    },
                                    pageSize: @(defaultGridPageSize),
                                    serverPaging: true,
                                    serverFiltering: true,
                                    serverSorting: true
                                },
                                pageable: {
                                    refresh: true,
                                    pageSizes: [@(gridPageSizes)]
                                },
                                editable: {
                                    confirmation: "@T("Admin.Common.DeleteConfirmation")",
                                    mode: "inline"
                                },
                                scrollable: false,
                                columns: [
                                    {
                                        field: "CustomNumber",
                                        title: "@T("Admin.ReturnRequests.Fields.CustomNumber")",
                                        width: 50
                                    }, {
                                        field: "ProductName",
                                        title: "@T("Admin.ReturnRequests.Fields.Product")",
                                        width: 200,
                                        template: '<a href="@Url.Content("~/Admin/Product/Edit/")#=ProductId#">#:ProductName#</a>'
                                    }, {
                                        field: "Quantity",
                                        title: "@T("Admin.ReturnRequests.Fields.Quantity")",
                                        width: 100
                                    }, {
                                        field: "CustomerId",
                                        title: "@T("Admin.ReturnRequests.Fields.Customer")",
                                        width: 200,
                                        template: '<a href="@Url.Content("~/Admin/Customer/Edit/")#=CustomerId#">#:CustomerInfo#</a>'
                                    }, {
                                        field: "OrderId",
                                        title: "@T("Admin.ReturnRequests.Fields.Order")",
                                        width: 200,
                                        template: '<a href="@Url.Content("~/Admin/Order/Edit/")#=OrderId#">#=OrderId# - @T("Admin.Common.View")</a>'
                                    }, {
                                        field: "ReturnRequestStatusStr",
                                        title: "@T("Admin.ReturnRequests.Fields.Status")",
                                        width: 100
                                    }, {
                                        field: "CreatedOn",
                                        title: "@T("Admin.ReturnRequests.Fields.CreatedOn")",
                                        width: 100,
                                        type: "date",
                                        format: "{0:G}"
                                    }, {
                                        field: "Id",
                                        title: "@T("Admin.Common.Edit")",
                                        width: 100,
                                        template: '<a href="Edit/#=Id#">@T("Admin.Common.Edit")</a>'
                                    }
                                ]
                            });
                        });
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
